import { IPSAppViewLogic } from '../../app/view/ipsapp-view-logic';
import { IPSModelObject } from '../../ipsmodel-object';
import { PSModelServiceProxyImpl } from '../../psmodel-service-proxy-impl';

/**
 * 全局默认通用代理
 *
 * @author chitanda
 * @date 2021-06-08 20:06:55
 * @export
 * @class PSAppDERSServiceProxy
 * @extends {PSModelServiceProxyImpl}
 */
export class PSAppViewLogicServiceProxy extends PSModelServiceProxyImpl {
  getPSModel4(
    relatedPSModelObject: IPSModelObject,
    cls: string,
    objNode: any,
    strTag: string,
  ): IPSModelObject {
    if (objNode.modelref === true) {
      switch (strTag) {
        case 'getPSAppDEUILogic':
          return this.getPSAppDEUILogic(
            relatedPSModelObject as IPSAppViewLogic,
            objNode,
          );
        case 'getPSAppUILogic':
          return this.getPSAppUILogic(
            relatedPSModelObject as IPSAppViewLogic,
            objNode,
          );
      }
    }
    return this.getRealPSModelService().getPSModel4(
      relatedPSModelObject,
      cls,
      objNode,
      strTag,
    );
  }

  getPSAppDEUILogic(r: IPSAppViewLogic, obj: any): any {
    const p = r.getPSAppDataEntity();
    if (p) {
      return p.findPSAppDEUILogic(obj);
    }
    return null;
  }

  getPSAppUILogic(r: IPSAppViewLogic, obj: any): any {
    return this.app.findPSAppUILogic(obj);
  }
}
